﻿@model Wiwi.ViewModels.WantCommunication
@{
    Layout = "../Shared/_Layout2.cshtml";
    ViewBag.Title = "Pitch Reply ";
    var HomeDir = System.Configuration.ConfigurationManager.AppSettings["HomeDirectory"].ToString(); 
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<!-- WiWi Reply -->

    <div class="grid_8 margin-top">
	
	  <div class="box-shadow z-index-20">
	
    	<h4 class="tabbed">Pitch Reply</h4>
<!-- -->
        <div class="wiwi-pitches-box">      
   	
   		<div class="left-col">
   			<a href="Home/UserPublicProfile?Uid=@Model.wnt.UserID" ><img height ="48" width="48" src='@Url.Action("ShowUserImage", "Home", new { Uid = @Model.wnt.UserID })' /></a>
   		</div>
   		
   		<div class="right-col bigger-icon">
   
   	    	<h5>@Model.wnt.FName <br />
           
            @if (Model.wnt.WiwiDate.Value != null)
             {
                 string durat = "";
                 if (Model.wnt.IsCreator == true) { durat = "Posted "; }
                 else { durat = "Me2'd "; }
                 TimeSpan span = DateTime.Now - Model.wnt.WiwiDate.Value;
                if (span.Days == 1)
                {
                    durat += span.Days.ToString() + " Day ";
                } else if(span.Days > 1) {
                    durat += span.Days.ToString() + " Days ";
                }
                if (span.Hours >= 1)
                {
                    durat += span.Hours.ToString() + " Hours ";
                }
                if (span.Minutes <= 59 && span.Minutes > 0)
                {
                    durat += span.Minutes.ToString() + " Minutes ";
                }
                durat += "ago";
                 <span >@durat</span>  @* "Posted 1 Day 1 Hours 6 Minutes ago" *@
             }</h5>
   	    	
       		<p class="serif-it">@Model.seller.pitchtext</p>						
   			
   	    	 <p class='tagged'>Tagged ~
             @if (Model.wnt.Tags != "")
             {
                 string[] TagRows = Model.wnt.Tags.Split('$');
                 foreach (string tr in TagRows)
                 {
                     if (tr != "")
                     {
                         string[] Tagss = tr.Split('?');
                         if (Tagss[0].Trim() != "")
                         {
                            <a href='/Want/Pitch?Wuid=@Tagss[1].ToString()'>@Tagss[0]</a>
                         }
                     }
                 }
             }
             </p>

   	    </div>
   	</div>    
   
   	<hr />
  <!-- #start reply -->

        @{
           int totFile = 0;           
        }
        @foreach (var cm in Model.comms)
        {
         <div class="wiwi-pitches-box"> 

            <div class="left-col">
         	    <a href="Home/UserPublicProfile?Uid=@Model.wnt.UserID" ><img height ="48" width="48" src='@Url.Action("ShowUserImage", "Home", new { Uid = @Model.wnt.UserID })' /></a>
            </div>   	
           
@* // User has it in their profile already
            @if (totFile == 0) {
                <ul class="user-choice">
   					<li><a href="#" class="green-button button-s xWide">Pitch Approved</a></li>
   			    </ul>
            }
  *@          
            <div class="right-col bigger-icon">

            <h5>@cm.FName<br /><span>Posted @cm.CommDate.ToString("dd/MM/yy")</span></h5>
            
            <p class="serif-it">@cm.Comments</p>

            @if (cm.At_ID != null)
            {
                totFile += 1;
                <span >@Html.ActionLink(cm.At_Name, "File", "Home", new { FileID = cm.At_ID }, null)</span>
            }
            </div>   
        </div>
            
         <hr class="mini" />
        }

    @* START inital post *@

    </div>
<!-- #start form -->
  <div class="grid_7 dark-bg" id="add-reply">
    
        <h5>Reply to thread</h5>

    	
@using (Html.BeginForm("WantComm", "Want", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    
    @Html.ValidationSummary(true, "File length exceeded by specified 3MB limit.")

        <input type ="hidden" id="UserID" name ="UserID" value="@Model.wnt.UserID" />
        <input type ="hidden" id="SellerID" name ="SellerID" value="@Model.seller.WantWanterSellerID" />
        <input type ="hidden" id="SuppID" name ="SuppID" value="@Model.seller.UserSellerID" />
        <input type ="hidden" id="Want_WanterID" name ="Want_WanterID" value="@Model.seller.Want_Wanter_RelID" />
    <div>
            @{
                if (Model.seller.CloseByUser == null)
            {
                <textarea cols="37" rows="4" class="serif-it" name="reply" id="reply" placeholder="Add reply"></textarea>
                
                if (totFile < 3)
                {
                <p class="white"><input type="file" id="file1" name ="file1" /></p>
                }
                <input type="submit" value="Add Reply" id="submit-button" /><br />
                {
                    MembershipUser usr = Membership.GetUser();
                    if (usr.ProviderUserKey.ToString() == Model.seller.UserSellerID.ToString())
                    {
                        
                    }
                    else
                    {
                        @Html.ActionLink("Close Deal", "CloseDeal", "want", new { SellerID = Model.seller.WantWanterSellerID }, null)
                    }
                }
            }

            }
            @{ MembershipUser usr1 = Membership.GetUser();
              if (usr1.ProviderUserKey.ToString() == Model.seller.UserSellerID.ToString())
              {
                        @Html.ActionLink("Request a feedback", "RequestFeedback", "want", new { SellerID = Model.seller.WantWanterSellerID }, new { @class="white"})
              }

            }
   </div> 
}

<!-- #end form -->

</div>

</div>

@*

@using (Html.BeginForm("WantComm", "Want", FormMethod.Post, new { enctype = "multipart/form-data" })) {
    
    @Html.ValidationSummary(true, "File length exceeded by specified 3MB limit.")
    <div class="grid_6" id="wiwi-sign-up">
        <div>
            
            <p>@Model.wnt.WantDesc</p>
            <p class='tagged'>Tagged ~
             @if (Model.wnt.Tags != "")
             {
                 string[] TagRows = Model.wnt.Tags.Split('$');
                 foreach (string tr in TagRows)
                 {
                     if (tr != "")
                     {
                         string[] Tagss = tr.Split('?');
                         if (Tagss[0].Trim() != "")
                         {
                            <a href='/Want/Pitch?Wuid=@Tagss[1].ToString()'>@Tagss[0]</a>
                         }
                     }
                 }
             }
             </p>
             
        </div>

        <hr />
        
        <div>
            <a href="Home/UserPublicProfile?Uid=@Model.seller.UserSellerID" ><img height ="48px" width="48" src='@Url.Action("ShowUserImage", "Home", new { Uid = @Model.seller.UserSellerID })' /></a> 
            <p>@Model.seller.pitchtext</p>
            @if (Model.seller.PitchDate.Value != null)
            {
                string durat = "";
                durat = "Posted ";
                TimeSpan span = DateTime.Now - Model.seller.PitchDate.Value;
                if (span.Days >= 1)
                {
                    durat += span.Days.ToString() + " Days ";
                }
                if (span.Hours >= 1)
                {
                    durat += span.Hours.ToString() + " Hours ";
                }
                if (span.Minutes <= 59 && span.Minutes > 0)
                {
                    durat += span.Minutes.ToString() + " Minutes ";
                }
                durat += "a go";
                 <span >@durat</span><br />
            }
               @if (Model.seller.PitchStatusChangeDate.Value != null)
               {
                   string durat = "";
                   durat = "Approved ";
                   TimeSpan span = DateTime.Now - Model.seller.PitchStatusChangeDate.Value;
                   if (span.Days >= 1)
                   {
                       durat += span.Days.ToString() + " Days ";
                   }
                   if (span.Hours >= 1)
                   {
                       durat += span.Hours.ToString() + " Hours ";
                   }
                   if (span.Minutes <= 59 && span.Minutes > 0)
                   {
                       durat += span.Minutes.ToString() + " Minutes ";
                   }
                   durat += "a go";
                 <span >@durat</span>
               }    
        </div>

        <hr />
        @{
               int totFile = 0;           
        }
        @foreach (var cm in Model.comms)
        {
         <div>
            <p>@cm.CommDate.ToString("dd/MM/yy") <span >@cm.FName</span></p>
            <p>@cm.Comments</p>
            @if (cm.At_ID != null)
            {
                totFile += 1;
                <span >@Html.ActionLink(cm.At_Name, "File", "Home", new { FileID = cm.At_ID }, null)</span>
            }
         </div>   
         <hr />
        }
        <div>
            <input type ="hidden" id="UserID" name ="UserID" value="@Model.wnt.UserID" />
            <input type ="hidden" id="SellerID" name ="SellerID" value="@Model.seller.WantWanterSellerID" />
            <input type ="hidden" id="SuppID" name ="SuppID" value="@Model.seller.UserSellerID" />
            <input type ="hidden" id="Want_WanterID" name ="Want_WanterID" value="@Model.seller.Want_Wanter_RelID" />
            @{
                if (Model.seller.CloseByUser == null)
            {
                <textarea rows ="3" cols="30" name="Reply" id="Reply" ></textarea><br />
                if (totFile < 3)
                {
                <input type="file" id="file1" name ="file1" /><br />
                }
                <input type ="submit" value ="Reply" /><br />
                {
                    MembershipUser usr = Membership.GetUser();
                    if (usr.ProviderUserKey.ToString() == Model.seller.UserSellerID.ToString())
                    {
                        
                    }
                    else
                    {
                        @Html.ActionLink("Close Deal", "CloseDeal", "want", new { SellerID = Model.seller.WantWanterSellerID }, null)
                    }
                }
            }

            }
            @{ MembershipUser usr1 = Membership.GetUser();
              if (usr1.ProviderUserKey.ToString() == Model.seller.UserSellerID.ToString())
              {
                        @Html.ActionLink("Request a feedback", "RequestFeedback", "want", new { SellerID = Model.seller.WantWanterSellerID }, null)
              }

            }
        </div>
    </div>
}
*@
